package cn.wawi.controller.data;

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import cn.wawi.common.Json;
import cn.wawi.common.easyui.DataGrid;
import cn.wawi.controller.BaseController;
import cn.wawi.entity.data.Skill;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/data_skill")
public class SkillController extends BaseController<Skill>{
	
	
	
	/**
	 * 技能列表,以json格式异步交互
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public DataGrid list(HttpServletRequest request){
		return findAllByPage(request);
	}
	
	@ResponseBody
	@RequestMapping(value="/savePost",method=RequestMethod.POST)
	public Json savePost(String gradeId,String skillId,String postIds){
		skillDao.deletePost(skillId);
		if(postIds!=null&&!"".equals(postIds.trim())){
			String[] posts=postIds.split(",");
			for (String post: posts) {
				Map<String,Object> map=new HashMap<String,Object>();
				map.put("skillId", skillId);
				map.put("gradeId", gradeId);
				map.put("postId", post);
				skillDao.savePost(map);
			}
		}
		return new Json("save", "添加岗位信息!");
	}
}
